package com.jobsika.solr.crawler;

import com.jobsika.domain.RPCPost;
import com.jobsika.domain.RPCUser;
import com.jobsika.solr.domain.Post;
import com.jobsika.solr.domain.User;

public class DataUtil {
	
	public static String extractCalifornia(String location) {
		location = location.toLowerCase();
		if (location.contains("cupertino")) {
//			System.out.println("cupertino-California-United_States");
			return "Cupertino-California-United_States";
		} else if (location.contains("san jose") || location.contains("willow glen") || location.contains("sj")) {
//			System.out.println("san_jose-California-United_States");
			return "San_Jose-California-United_States";
		} else if (location.contains("san francisco") || location.contains("sf") || location.contains("s.f")) {
//			System.out.println("san_jose-California-United_States");
			return "San_Francisco-California-United_States";
		} else if (location.contains("santa clara")) {
//			System.out.println("santa_clara-California-United_States");
			return "Santa_Clara-California-United_States";
		} else if (location.contains("los gatos")) {
//			System.out.println("los_gatos-California-United_States");
			return "Los_Gatos-California-United_States";
		} else if (location.contains("campbell")) {
//			System.out.println("campbell-California-United_States");
			return "Campbell-California-United_States";
		} else if (location.contains("morgan hill")) {
//			System.out.println("morgan_hill-California-United_States");
			return "Morgan_Hill-California-United_States";
		} else if (location.contains("sunnyvale")) {
//			System.out.println("sunnyvale-California-United_States");
			return "Sunnyvale-California-United_States";
		} else if (location.contains("rancho cordova")) {
//			System.out.println("rancho_cordova-California-United_States");
			return "Rancho_Cordova-California-United_States";
		} else if (location.contains("monterey")) {
//			System.out.println("monterey-California-United_States");
			return "Monterey-California-United_States";
		} else if (location.contains("mountain view")) {
//			System.out.println("mountain_view-California-United_States");
			return "Mountain_View-California-United_States";
		} else if (location.contains("milpitas")) {
//			System.out.println("milpitas-California-United_States");
			return "Milpitas-California-United_States";
		} else if (location.contains("palo alto")) {
//			System.out.println("palo_alto-California-United_States");
			return "Palo_Alto-California-United_States";
		} else if (location.contains("redwood city")) {
//			System.out.println("redwood_city-California-United_States");
			return "Redwood_City-California-United_States";
		} else if (location.contains("hayward")) {
//			System.out.println("hayward-California-United_States");
			return "Hayward-California-United_States";
		} else if (location.contains("gilroy")) {
//			System.out.println("gilroy-California-United_States");
			return "Gilroy-California-United_States";
		} else if (location.contains("sacramento")) {
//			System.out.println("sacramento-California-United_States");
			return "Sacramento-California-United_States";
		} else if (location.contains("saratoga")) {
//			System.out.println("saratoga-California-United_States");
			return "Saratoga-California-United_States";
		} else if (location.contains("menlo park")) {
//			System.out.println("menlo_park-California-United_States");
			return "Menlo_Park-California-United_States";
		} else if (location.contains("fremont")) {
//			System.out.println("fremont-California-United_States");
			return "Fremont-California-United_States";
		} else if (location.contains("salinas")) {
//			System.out.println("salinas-California-United_States");
			return "Salinas-California-United_States";
		} else if (location.contains("roseville")) {
//			System.out.println("roseville-California-United_States");
			return "Roseville-California-United_States";
		} else if (location.contains("loomis")) {
//			System.out.println("loomis-California-United_States");
			return "Loomis-California-United_States";
		} else if (location.contains("torrance")) {
//			System.out.println("torrance-California-United_States");
			return "Torrance-California-United_States";
		} else if (location.contains("oakland")) {
//			System.out.println("oakland-California-United_States");
			return "Oakland-California-United_States";
		} else if (location.contains("silicon valley")) {
//			System.out.println("silicon_valley-California-United_States");
			return "Silicon_Valley-California-United_States";
		} else if (location.contains("peninsula")) {
//			System.out.println("bay_area-California-United_States");
			return "Bay_Area-California-United_States";
		} else if (location.contains("santa cruz")) {
//			System.out.println("santa_cruz-California-United_States");
			return "Santa_Cruz-California-United_States";
		} else if (location.contains("fairfield")) {
//			System.out.println("fairfield-California-United_States");
			return "Fairfield-California-United_States";
		} else if (location.contains("vacaville")) {
//			System.out.println("vacaville-California-United_States");
			return "Vacaville-California-United_States";
		} else if (location.contains("hollister")) {
//			System.out.println("hollister-California-United_States");
			return "Hollister-California-United_States";
		} else if (location.contains("concord")) {
//			System.out.println("concord-California-United_States");
			return "Concord-California-United_States";
		} else if (location.contains("pleasanton")) {
//			System.out.println("pleasanton-California-United_States");
			return "Pleasanton-California-United_States";
		} else if (location.contains("san bruno")) {
//			System.out.println("san_bruno-California-United_States");
			return "San_Bruno-California-United_States";
		} else if (location.contains("los altos")) {
//			System.out.println("los_altos-California-United_States");
			return "Los_Altos-California-United_States";
		} else if (location.contains("lake tahoe")) {
//			System.out.println("lake_tahoe-California-United_States");
			return "Lake_Tahoe-California-United_States";
		} else if (location.contains("san mateo")) {
//			System.out.println("san_mateo-California-United_States");
			return "San_Mateo-California-United_States";
		} else if (location.contains("bay area") || location.contains("bay") || location.contains("south bay")) {
//			System.out.println("bay_area-California-United_States");
			return "Bay_Area-California-United_States";
		} else {
			System.out.println(location);	
		}
		return "Uncategorized";
	}
	
	public static String extractInfo(String title, String body) {
		title = title.toLowerCase();
		if (title.contains("cold fusion")) {
			
		} else if (title.contains("javascript")) {
			
		} else if (title.contains("sql") || title.contains("storage")) {
			
		} else if (title.contains("c") || title.contains("c++")) {
			
		}
		return "nakama";
	}
	
	public static RPCPost toRPC(Post post) {
		RPCPost result = new RPCPost(post.getTitle(), post.getLocation(), post.getId(), post.getDate(), post.getBody());
		return result;
	}
	
	public static RPCUser toRPC(User user) {
		RPCUser result = new RPCUser(user.getEmail(), user.getFirstName(), user.getLastName(), user.getSchool(), user.getEmployer());
		result.setRegistered(user.isRegistered());
		return result;
	}
	
	public static User toRPC(RPCUser user) {
		User result = new User(user.getFirstName(), user.getLastName(), user.getEmail(), user.getSchool(), user.getEmployer());
		result.setRegistered(user.isRegistered());
		return result;
	}
}
